package cc.linker.steplink.crm.merchanth5.controller;


import cc.linker.steplink.crm.commons.Constants;
import cc.linker.steplink.crm.commons.domain.WxUser;
import cc.linker.steplink.crm.merchanth5.commons.RequestFilter;
import cc.linker.steplink.crm.merchanth5.service.ZsGoodsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;


/**
 * 知识付费货架商城
 */

@RequestMapping("/h5/zsgoods")
@RestController
public class ZsGoodsController {


    @Autowired
    private ZsGoodsService zsGoodsService;

    @Autowired
    private RequestFilter requestFilter;


    //获取货架商城列表
    @GetMapping("/getlist")
    public PageInfo<Map<String, Object>> getList(@RequestParam(defaultValue = "20") Integer pageSize,
                                                 @RequestParam(defaultValue = "1") Integer pageIndex,
                                                 HttpServletRequest request){
        WxUser wxUser =  requestFilter.getWxUser(request);
        String orgId = wxUser.getOrgId();
        PageHelper.startPage(pageIndex, pageSize);
        return new PageInfo<>(zsGoodsService.getList(orgId));
    }

}
